<?php


namespace app\admin\controller;

use app\common\controller\BasicAdmin;
use app\common\traits\SelectPage;

/**
 * Class CourseCate
 */
class CourseCate extends BasicAdmin
{
    use SelectPage;

    protected $model = 'CourseCateModel';

    /**
     * 分类管理
     */
    public function index()
    {
        $this->title = '分类管理';
        return  $this->_query($this->model)
            ->like('name')
            ->order('id desc')
            ->page();
    }

    /**
     * 添加分类
     */
    public function add()
    {
        $this->title = '添加分类';
        return $this->_form($this->model, 'form');
    }

    /**
     * 编辑分类
     */
    public function edit()
    {
        $this->title = '编辑分类';
        return $this->_form($this->model, 'form');
    }

    /**
     * 删除分类
     */
    public function del()
    {
        $this->_delete($this->model);
    }

    /**
     * 启用/关闭
     */
    public function upstatus(){
        $this->_save($this->model, [
            'status' => $this->request->request('status'),
        ],'id', ['id' => $this->request->request('id')]);
    }
}